package cn.iocoder.yudao.module.xiaoBizHandler.service.codegen.newInner.yudao.handler;

import cn.iocoder.yudao.module.xiaoBizHandler.dal.dataobject.codegen.XiaoBizHandlerCodegenColumnDO;
import cn.iocoder.yudao.module.xiaoBizHandler.dal.dataobject.codegen.XiaoBizHandlerCodegenTableDO;
import cn.iocoder.yudao.module.xiaoBizHandler.service.codegen.newInner.GlobalBinding;
import cn.iocoder.yudao.module.xiaoBizHandler.service.codegen.newInner.LocalBinding;
import lombok.Builder;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
@Builder
public class PathHandler {

    XiaoBizHandlerCodegenTableDO table = null;
    List<XiaoBizHandlerCodegenColumnDO> columns = new ArrayList<>();
    GlobalBinding globalBinding = null;
    LocalBinding localBinding = null;
    XiaoBizHandlerCodegenColumnDO primaryColumn = null;


    public String javaModuleImplVOFilePath(String path) {
        return javaModuleFilePath("controller/" + localBinding.getSceneEnum().getBasePackage() + "/" + table.getBusinessName() + "/" +
                "vo/" + localBinding.getSceneEnum().getPrefixClass() + "" + table.getClassName() + "" + path, "impl", "main");
    }

    public String javaModuleImplControllerFilePath() {
        return javaModuleFilePath("controller/" + localBinding.getSceneEnum().getBasePackage() + "/" + table.getBusinessName() + "/" +
                "" + localBinding.getSceneEnum().getPrefixClass() + "" + table.getClassName() + "Controller", "impl", "main");
    }

    public String javaModuleImplMainFilePath(String path) {
        return javaModuleFilePath(path, "impl", "main");
    }

    public String javaModuleApiMainFilePath(String path) {
        return javaModuleFilePath(path, "api", "main");
    }

    public String javaModuleImplTestFilePath(String path) {
        return javaModuleFilePath(path, "impl", "test");
    }

    public String javaModuleFilePath(String path, String module, String src) {
        return "yudao-module-" + table.getModuleName() + "/" + // 顶级模块
                "yudao-module-" + table.getModuleName() + "-" + module + "/" + // 子模块
                "src/" + src + "/java/" + globalBinding.getBasePackage().replace(".", "/") + "/module/" + table.getModuleName() + "/" + path + ".java";
    }

    public String mapperXmlFilePath() {
        return "yudao-module-" + table.getModuleName() + "/" + // 顶级模块
                "yudao-module-" + table.getModuleName() + "-impl/" + // 子模块
                "src/resources/mapper/" + table.getBusinessName() + "/" + table.getClassName() + "Mapper.xml";
    }

    public String vueTemplatePath(String path) {
        return "codegen/vue/" + path + ".vm";
    }

    public String vueFilePath(String path) {
        return "yudao-ui- " + localBinding.getSceneEnum().getBasePackage() + "/" + // 顶级目录
                "src/" + path;
    }


}
